package vetAdmin.swing;

import javax.swing.GroupLayout.Alignment;
import javax.swing.GroupLayout;
import javax.swing.JDesktopPane;
import javax.swing.JOptionPane;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JTable;
import javax.swing.Timer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableModel;
import javax.swing.JScrollPane;
import com.tutorialjava.bd.*;
import javax.swing.border.TitledBorder;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.UIManager;
import java.awt.Color;
import javax.swing.ListSelectionModel;
import javax.swing.border.SoftBevelBorder;
import javax.swing.border.BevelBorder;
import javax.swing.JButton;
import java.awt.Font;
import javax.swing.SwingConstants;
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.ListIterator;

import javax.swing.DefaultComboBoxModel;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Component;
import vetAdmin.dao.ClienteDAO;
import vetAdmin.dao.implementation.ClienteDAOJDBC;
import vetAdmin.listeners.ClientesTableListener;
import vetAdmin.model.Cliente;
import vetAdmin.model.Paciente;
import vetAdmin.tableModels.ClientesJTableModel;
import vetAdmin.tableModels.PacientesJTableModel;

public class ClienteFrame extends javax.swing.JInternalFrame {

	 // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton abrirFichaButton;
    private com.toedter.calendar.JDateChooser altaClienteDate;
    private javax.swing.JLabel altaClienteLabel;
    private javax.swing.JButton busquedaButton;
    private javax.swing.JTextField busquedaField;
    private javax.swing.JTextField celularField;
    private javax.swing.JLabel celularLabel;
    private javax.swing.JPanel clientesPanel;
    private javax.swing.JTextField codArea1Field;
    private javax.swing.JTextField codArea2Field;
    private javax.swing.JComboBox cpComboBox;
    private javax.swing.JLabel cpLabel;
    private javax.swing.JTextField direccionField;
    private javax.swing.JLabel direccionLabel;
    private javax.swing.JTextField edadField;
    private javax.swing.JLabel edadLabel;
    private javax.swing.JButton eliminarClienteButton;
    private javax.swing.JTextField emailField;
    private javax.swing.JLabel emailLabel;
    private javax.swing.JComboBox especieComboBox;
    private javax.swing.JLabel especieLabel;
    private com.toedter.calendar.JDateChooser fAltaDate;
    private javax.swing.JLabel fAltaLabel;
    private com.toedter.calendar.JDateChooser fNacDate;
    private javax.swing.JLabel fNacLabel;
    private javax.swing.JLabel fUltVisitaLabel;
    private com.toedter.calendar.JDateChooser fUltimaVisitaDate;
    private javax.swing.JButton guardarClienteButton;
    private javax.swing.JButton guardarDatosClienteButton;
    private javax.swing.JButton guardarPacienteButton;
    private javax.swing.JTextField idField;
    private javax.swing.JLabel idLabel;
    private javax.swing.JTextField idPacienteField;
    private javax.swing.JLabel idPacienteLabel;
    private javax.swing.JPanel infoClientePanel;
    private javax.swing.JPanel infoPacientePanel;
    private javax.swing.JComboBox localidadComboBox;
    private javax.swing.JLabel localidadLabel;
    private javax.swing.JTextField microchipField;
    private javax.swing.JLabel microchipLabel;
    private javax.swing.JButton modificarPacienteButton;
    private javax.swing.JTextField nombreApellidoField;
    private javax.swing.JLabel nombreApellidoLabel;
    private javax.swing.JTextField nombrePacienteField;
    private javax.swing.JLabel nombrePacienteLabel;
    private javax.swing.JButton nuevoClienteButton;
    private javax.swing.JButton nuevoPacienteButton;
    private javax.swing.JPanel pacientesPanel;
    private javax.swing.JTextField pelajeField;
    private javax.swing.JLabel pelajeLabel;
    private javax.swing.JComboBox provinciaComboBox;
    private javax.swing.JLabel provinciaLabel;
    private javax.swing.JComboBox razaComboBox;
    private javax.swing.JLabel razaLabel;
    private javax.swing.JComboBox sexoComboBox;
    private javax.swing.JLabel sexoLabel;
    private javax.swing.JTextField telefonoField;
    private javax.swing.JLabel telefonoLabel;
    private com.toedter.calendar.JDateChooser ultVisitaClienteDate;
    private javax.swing.JLabel ultVisitaClienteLabel;
    
    private DefaultTableModel clientesTableModel;
    
    private DefaultTableModel pacientesTableModel;    
    
    
    private JButton btnEditar;
   
    /**
     * Dao de cliente
     */
    //ClienteDAO dao = new ClienteDAOJDBC();
    
//    ArrayList<Cliente> clientes = (ArrayList<Cliente>) dao.getAll();
    
    private JTable clientesTable;
    private JTable pacientesTable;
   
    
    // End of variables declaration//GEN-END:variables

	
   
    public ClienteFrame() {
    	setResizable(true);
    	setClosable(true);
        initComponents();
    }
  	
    
   
    
    private void initComponents() {

        clientesPanel = new javax.swing.JPanel();
        busquedaField = new javax.swing.JTextField();
        busquedaButton = new javax.swing.JButton();
        pacientesPanel = new javax.swing.JPanel();
        infoClientePanel = new javax.swing.JPanel();
        nombreApellidoLabel = new javax.swing.JLabel();
        idLabel = new javax.swing.JLabel();
        idField = new javax.swing.JTextField();
        idField.setText("0");
        nombreApellidoField = new javax.swing.JTextField();
        nombreApellidoField.setEnabled(false);
        direccionLabel = new javax.swing.JLabel();
        direccionField = new javax.swing.JTextField();
        direccionField.setEnabled(false);
        cpLabel = new javax.swing.JLabel();
        cpComboBox = new javax.swing.JComboBox();
        localidadLabel = new javax.swing.JLabel();
        localidadComboBox = new javax.swing.JComboBox();
        localidadComboBox.setEnabled(false);
        provinciaLabel = new javax.swing.JLabel();
        provinciaComboBox = new javax.swing.JComboBox();
        provinciaComboBox.setModel(new DefaultComboBoxModel(new String[] {"Buenos Aires"}));
        provinciaComboBox.setEnabled(false);
        telefonoLabel = new javax.swing.JLabel();
        codArea1Field = new javax.swing.JTextField();
        codArea1Field.setEnabled(false);
        telefonoField = new javax.swing.JTextField();
        telefonoField.setEnabled(false);
        celularLabel = new javax.swing.JLabel();
        celularField = new javax.swing.JTextField();
        celularField.setEnabled(false);
        codArea2Field = new javax.swing.JTextField();
        codArea2Field.setEnabled(false);
        emailLabel = new javax.swing.JLabel();
        emailField = new javax.swing.JTextField();
        emailField.setEnabled(false);
        altaClienteLabel = new javax.swing.JLabel();
        ultVisitaClienteLabel = new javax.swing.JLabel();
        ultVisitaClienteDate = new com.toedter.calendar.JDateChooser();
        ultVisitaClienteDate.setDateFormatString("dd/mm/yyyy");
        altaClienteDate = new com.toedter.calendar.JDateChooser();
        altaClienteDate.setDateFormatString("dd/mm/yyyy");
        guardarClienteButton = new javax.swing.JButton();
        eliminarClienteButton = new javax.swing.JButton();
        guardarDatosClienteButton = new javax.swing.JButton();
        infoPacientePanel = new javax.swing.JPanel();
        idPacienteField = new javax.swing.JTextField();
        idPacienteLabel = new javax.swing.JLabel();
        nombrePacienteLabel = new javax.swing.JLabel();
        nombrePacienteField = new javax.swing.JTextField();
        especieLabel = new javax.swing.JLabel();
        especieComboBox = new javax.swing.JComboBox();
        razaLabel = new javax.swing.JLabel();
        razaComboBox = new javax.swing.JComboBox();
        sexoLabel = new javax.swing.JLabel();
        sexoComboBox = new javax.swing.JComboBox();
        fNacLabel = new javax.swing.JLabel();
        fNacDate = new com.toedter.calendar.JDateChooser();
        edadLabel = new javax.swing.JLabel();
        pelajeLabel = new javax.swing.JLabel();
        pelajeField = new javax.swing.JTextField();
        edadField = new javax.swing.JTextField();
        fAltaLabel = new javax.swing.JLabel();
        fAltaDate = new com.toedter.calendar.JDateChooser();
        fUltVisitaLabel = new javax.swing.JLabel();
        fUltimaVisitaDate = new com.toedter.calendar.JDateChooser();
        microchipLabel = new javax.swing.JLabel();
        microchipField = new javax.swing.JTextField();
        nuevoPacienteButton = new javax.swing.JButton();
        modificarPacienteButton = new javax.swing.JButton();
        guardarPacienteButton = new javax.swing.JButton();
        
        clientesTableModel = new DefaultTableModel() {
            
			private static final long serialVersionUID = 1L;

			@Override
            public boolean isCellEditable (int row, int column) {
            	return false;
            }
        	
        	
        };
        
        
        clientesTable = new JTable();         
        
        clientesTableModel.addColumn("Apellido y Nombre");         
        
        clientesTable.setShowGrid(false);
        
        clientesTable.setModel(clientesTableModel);   
        
        clientesTable.getModel().addTableModelListener(new ClientesTableListener(clientesTable));
       
     
    	clientesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

			@Override
			public void valueChanged(ListSelectionEvent arg0) {			
				
				pacientesTableModel.setRowCount(0); 			
		
				borrarDatosPacienteEnCampos();
				
				MostrarDatosDeTablaClientes();	
						
				setEstadoDeEdicionCliente(false);
				
			}
    		
        });
    	
    	clientesTableModel.addTableModelListener(clientesTable);
    	       
    	pacientesTableModel = new DefaultTableModel() {
            
			private static final long serialVersionUID = 1L;

			@Override
            public boolean isCellEditable (int row, int column) {
            	return false;
            }	
			
        	
        };
        
        
        
     
    	pacientesTable = new JTable();
    	
    	pacientesTableModel.addColumn("Nombre");
    	
    	pacientesTable.setModel(pacientesTableModel);

    	pacientesTable.setShowGrid(false);
    	
 //   	pacientesTableModel.addTableModelListener(pacientesTable);
    	
       	pacientesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

			@Override
			public void valueChanged(ListSelectionEvent arg0) {
				
				if (pacientesTableModel.getRowCount() > 0) {						
					mostrarDatosDeTablaPacientes();	
					setEstadoDeEdicionPaciente(false);
				}
							
				
				setEstadoDeEdicionCliente(false);
				
			}
    		
        });
    	
    	
    	

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("VetAdmin");

        clientesPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Clientes", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12))); // NOI18N
        clientesPanel.setName("clientesPanel"); // NOI18N

        busquedaField.setName("busquedaField"); // NOI18N

        busquedaButton.setText("Buscar");
        busquedaButton.setName("busquedaButton");

        pacientesPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Pacientes", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12))); // NOI18N
        pacientesPanel.setName("pacientesPanel");

        
        infoClientePanel.setBorder(new TitledBorder(null, "Informaci\u00F3n de Cliente", TitledBorder.LEADING, TitledBorder.TOP, null, null)); // NOI18N
        infoClientePanel.setName("infoClientePanel"); // NOI18N

        nombreApellidoLabel.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        nombreApellidoLabel.setText("Apellido y Nombre:");
        nombreApellidoLabel.setName("nombreApellidoLabel"); // NOI18N

        idLabel.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        idLabel.setText("ID:");
        idLabel.setName("idLabel"); // NOI18N

        idField.setEditable(false);
        idField.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        idField.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        idField.setName("idField"); // NOI18N
        idField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
        
            }
        });

        nombreApellidoField.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        nombreApellidoField.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        nombreApellidoField.setName("nombreApellidoField"); // NOI18N

        direccionLabel.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        direccionLabel.setText("Direcci\u00F3n:");
        direccionLabel.setName("direccionLabel"); // NOI18N

        direccionField.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        direccionField.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        direccionField.setName("direccionField"); // NOI18N
        direccionField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
              
            }
        });

        cpLabel.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        cpLabel.setText("CP:");
        cpLabel.setName("cpLabel"); // NOI18N

        cpComboBox.setEditable(true);
        cpComboBox.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        cpComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1885", "1884" }));
        cpComboBox.setBorder(null);
        cpComboBox.setName("cpComboBox"); // NOI18N

        localidadLabel.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        localidadLabel.setText("Localidad:");
        localidadLabel.setName("localidadLabel"); // NOI18N

        localidadComboBox.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        localidadComboBox.setModel(new DefaultComboBoxModel(new String[] {"Berazategui", "Guillermo E. Hudson", "Pl\u00E1tanos", "Barrio Mar\u00EDtimo"}));
        localidadComboBox.setName("localidadComboBox"); // NOI18N

        provinciaLabel.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        provinciaLabel.setText("Provincia:");
        provinciaLabel.setName("provinciaLabel"); // NOI18N

        provinciaComboBox.setFont(new java.awt.Font("Arial", 0, 14));
        provinciaComboBox.setName("provinciaComboBox"); // NOI18N

        telefonoLabel.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        telefonoLabel.setText("Tel\u00E9fono:");
        telefonoLabel.setName("telefonoLabel"); // NOI18N

        codArea1Field.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        codArea1Field.setText("011");
        codArea1Field.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        codArea1Field.setName("codArea1Field"); // NOI18N

        telefonoField.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        telefonoField.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        telefonoField.setName("telefonoField"); // NOI18N
        telefonoField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
              
            }
        });

        celularLabel.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        celularLabel.setText("Celular:");
        celularLabel.setName("celularLabel"); // NOI18N

        celularField.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        celularField.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        celularField.setName("celularField"); // NOI18N
        celularField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
              
            }
        });

        codArea2Field.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        codArea2Field.setText("011");
        codArea2Field.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        codArea2Field.setName("codArea2Field"); // NOI18N

        emailLabel.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        emailLabel.setText("E-mail:");
        emailLabel.setName("emailLabel"); // NOI18N

        emailField.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        emailField.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        emailField.setName("emailField"); // NOI18N

        altaClienteLabel.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        altaClienteLabel.setText("Fecha de Alta:");
        altaClienteLabel.setName("altaClienteLabel"); // NOI18N

        ultVisitaClienteLabel.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        ultVisitaClienteLabel.setText("Fecha de \u00FAltima visita:");
        ultVisitaClienteLabel.setName("ultVisitaClienteLabel"); // NOI18N

        ultVisitaClienteDate.setName("ultVisitaClienteDate"); // NOI18N

        altaClienteDate.setMaxSelectableDate(new java.util.Date());
        altaClienteDate.setName("altaClienteDate"); // NOI18N
        
	 	nuevoClienteButton = new javax.swing.JButton();
        
        nuevoClienteButton.setFont(new java.awt.Font("Arial", 0, 24)); // NOI18N
        nuevoClienteButton.setText("Nuevo Cliente");
        nuevoClienteButton.setBorder(new SoftBevelBorder(BevelBorder.RAISED, null, null, null, null));
        nuevoClienteButton.setFocusable(false);
        nuevoClienteButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        nuevoClienteButton.setName("nuevoClienteButton"); // NOI18N
        nuevoClienteButton.setPreferredSize(new java.awt.Dimension(81, 19));
        nuevoClienteButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        
        nuevoClienteButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
            	 setEstadoDeEdicionCliente(true);
            	
                 try {
                 	
                 //	int proximoCodigoCliente = dao.nextIdValue();
                 //	idField.setText(proximoCodigoCliente +"");
         		
                 } catch (Exception e) {
         		
         		}
                 
                 nombreApellidoField.setRequestFocusEnabled(true); // pone el cursor sobre el campo
                 nombreApellidoField.setText("");
                 direccionField.setText("");
                 telefonoField.setText("");
                 celularField.setText("");
                 emailField.setText("");
                 altaClienteDate.setDate(new Date());
                 ultVisitaClienteDate.setDate(new Date());
                        
            }
        });


        eliminarClienteButton.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        eliminarClienteButton.setText("Eliminar cliente");
        eliminarClienteButton.setBorder(null);
        eliminarClienteButton.setFocusable(false);
        eliminarClienteButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        eliminarClienteButton.setName("eliminarClienteButton"); // NOI18N
        eliminarClienteButton.setPreferredSize(new java.awt.Dimension(81, 19));
        eliminarClienteButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        eliminarClienteButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {

                Integer codigo = Integer.parseInt(idField.getText());

//                dao.deleteById(codigo);
           
                setEstadoDeEdicionCliente(false);
            }
        });

        guardarDatosClienteButton.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        guardarDatosClienteButton.setText("Guardar");
        guardarDatosClienteButton.setBorder(null);
        guardarDatosClienteButton.setFocusable(false);
        guardarDatosClienteButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        guardarDatosClienteButton.setName("guardarDatosClienteButton"); // NOI18N
        guardarDatosClienteButton.setPreferredSize(new java.awt.Dimension(81, 19));
        guardarDatosClienteButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        
        guardarDatosClienteButton.addActionListener(new java.awt.event.ActionListener() {            
        	
        public void actionPerformed(java.awt.event.ActionEvent evt) {
                
        /*        Cliente cliente = new Cliente(Integer.parseInt(idField.getText()),nombreApellidoField.getText(), direccionField.getText(), telefonoField.getText(),localidadComboBox.getSelectedItem().toString(),
                									provinciaComboBox.getSelectedItem().toString(),cpComboBox.getSelectedItem().toString(), codArea1Field.getText(), codArea2Field.getText(), 
                									celularField.getText(), emailField.getText(), null, null);
                
                setEstadoDeEdicionCliente(false);
                dao.save(cliente);  
                clientesTableModel.fireTableDataChanged();
          */
              }
        });
   
        
        btnEditar = new JButton();
      
        btnEditar.setVerticalTextPosition(SwingConstants.BOTTOM);
        btnEditar.setText("Editar");
        btnEditar.setPreferredSize(new Dimension(81, 19));
        btnEditar.setName("abrirFichaButton");
        btnEditar.setHorizontalTextPosition(SwingConstants.CENTER);
        btnEditar.setFont(new Font("Arial", Font.PLAIN, 18));
        btnEditar.setFocusable(false);
        btnEditar.setBorder(null);
        
        btnEditar.addActionListener(new ActionListener() {
        	public void actionPerformed(ActionEvent arg0) {
        		setEstadoDeEdicionCliente(true);
        		nombreApellidoField.setRequestFocusEnabled(true);     
        		
        	}
        });
        

        javax.swing.GroupLayout infoClientePanelLayout = new javax.swing.GroupLayout(infoClientePanel);
        infoClientePanelLayout.setHorizontalGroup(
        	infoClientePanelLayout.createParallelGroup(Alignment.LEADING)
        		.addGroup(infoClientePanelLayout.createSequentialGroup()
        			.addGroup(infoClientePanelLayout.createParallelGroup(Alignment.LEADING)
        				.addGroup(infoClientePanelLayout.createSequentialGroup()
        					.addContainerGap()
        					.addGroup(infoClientePanelLayout.createParallelGroup(Alignment.LEADING)
        						.addComponent(idLabel)
        						.addGroup(infoClientePanelLayout.createSequentialGroup()
        							.addGroup(infoClientePanelLayout.createParallelGroup(Alignment.LEADING)
        								.addComponent(cpLabel)
        								.addComponent(nombreApellidoLabel)
        								.addComponent(emailLabel)
        								.addComponent(altaClienteLabel)
        								.addComponent(direccionLabel)
        								.addComponent(telefonoLabel, GroupLayout.PREFERRED_SIZE, 91, GroupLayout.PREFERRED_SIZE))
        							.addPreferredGap(ComponentPlacement.RELATED)
        							.addGroup(infoClientePanelLayout.createParallelGroup(Alignment.TRAILING)
        								.addGroup(infoClientePanelLayout.createSequentialGroup()
        									.addGroup(infoClientePanelLayout.createParallelGroup(Alignment.LEADING)
        										.addComponent(emailField, GroupLayout.DEFAULT_SIZE, 538, Short.MAX_VALUE)
        										.addGroup(infoClientePanelLayout.createSequentialGroup()
        											.addComponent(codArea1Field, GroupLayout.PREFERRED_SIZE, 51, GroupLayout.PREFERRED_SIZE)
        											.addPreferredGap(ComponentPlacement.RELATED)
        											.addComponent(telefonoField, GroupLayout.PREFERRED_SIZE, 298, GroupLayout.PREFERRED_SIZE))
        										.addGroup(infoClientePanelLayout.createSequentialGroup()
        											.addComponent(altaClienteDate, GroupLayout.PREFERRED_SIZE, 247, GroupLayout.PREFERRED_SIZE)
        											.addGap(18)
        											.addComponent(ultVisitaClienteLabel)
        											.addGap(10)
        											.addComponent(ultVisitaClienteDate, GroupLayout.DEFAULT_SIZE, 106, Short.MAX_VALUE)))
        									.addGap(353))
        								.addGroup(infoClientePanelLayout.createSequentialGroup()
        									.addGroup(infoClientePanelLayout.createParallelGroup(Alignment.LEADING)
        										.addGroup(infoClientePanelLayout.createSequentialGroup()
        											.addComponent(idField, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
        											.addPreferredGap(ComponentPlacement.RELATED, 550, Short.MAX_VALUE)
        											.addComponent(eliminarClienteButton, GroupLayout.PREFERRED_SIZE, 137, GroupLayout.PREFERRED_SIZE))
        										.addGroup(infoClientePanelLayout.createSequentialGroup()
        											.addComponent(cpComboBox, GroupLayout.PREFERRED_SIZE, 68, GroupLayout.PREFERRED_SIZE)
        											.addGap(18)
        											.addComponent(localidadLabel)
        											.addPreferredGap(ComponentPlacement.UNRELATED)
        											.addComponent(localidadComboBox, GroupLayout.PREFERRED_SIZE, 202, GroupLayout.PREFERRED_SIZE)
        											.addGap(18)
        											.addGroup(infoClientePanelLayout.createParallelGroup(Alignment.LEADING)
        												.addGroup(infoClientePanelLayout.createSequentialGroup()
        													.addComponent(celularLabel)
        													.addGap(18)
        													.addComponent(codArea2Field, GroupLayout.PREFERRED_SIZE, 51, GroupLayout.PREFERRED_SIZE)
        													.addPreferredGap(ComponentPlacement.RELATED)
        													.addComponent(celularField, GroupLayout.DEFAULT_SIZE, 241, Short.MAX_VALUE))
        												.addGroup(infoClientePanelLayout.createSequentialGroup()
        													.addComponent(provinciaLabel)
        													.addPreferredGap(ComponentPlacement.RELATED)
        													.addComponent(provinciaComboBox, 0, 296, Short.MAX_VALUE))))
        										.addGroup(infoClientePanelLayout.createParallelGroup(Alignment.TRAILING, false)
        											.addComponent(direccionField, Alignment.LEADING)
        											.addComponent(nombreApellidoField, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 757, Short.MAX_VALUE)))
        									.addGap(101)
        									.addComponent(guardarClienteButton))))))
        				.addGroup(infoClientePanelLayout.createSequentialGroup()
        					.addGap(254)
        					.addComponent(guardarDatosClienteButton, GroupLayout.PREFERRED_SIZE, 97, GroupLayout.PREFERRED_SIZE)
        					.addGap(30)
        					.addComponent(btnEditar, GroupLayout.PREFERRED_SIZE, 73, GroupLayout.PREFERRED_SIZE)))
        			.addContainerGap())
        );
        infoClientePanelLayout.setVerticalGroup(
        	infoClientePanelLayout.createParallelGroup(Alignment.LEADING)
        		.addGroup(infoClientePanelLayout.createSequentialGroup()
        			.addContainerGap()
        			.addGroup(infoClientePanelLayout.createParallelGroup(Alignment.LEADING)
        				.addGroup(infoClientePanelLayout.createParallelGroup(Alignment.BASELINE)
        					.addComponent(idLabel)
        					.addComponent(idField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
        					.addComponent(guardarClienteButton))
        				.addComponent(eliminarClienteButton, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE))
        			.addPreferredGap(ComponentPlacement.UNRELATED)
        			.addGroup(infoClientePanelLayout.createParallelGroup(Alignment.BASELINE)
        				.addComponent(nombreApellidoLabel)
        				.addComponent(nombreApellidoField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
        			.addPreferredGap(ComponentPlacement.RELATED)
        			.addGroup(infoClientePanelLayout.createParallelGroup(Alignment.BASELINE)
        				.addComponent(direccionField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
        				.addComponent(direccionLabel))
        			.addPreferredGap(ComponentPlacement.RELATED)
        			.addGroup(infoClientePanelLayout.createParallelGroup(Alignment.BASELINE)
        				.addComponent(cpLabel)
        				.addComponent(cpComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
        				.addComponent(provinciaComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
        				.addComponent(localidadComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
        				.addComponent(localidadLabel)
        				.addComponent(provinciaLabel))
        			.addPreferredGap(ComponentPlacement.RELATED)
        			.addGroup(infoClientePanelLayout.createParallelGroup(Alignment.BASELINE)
        				.addComponent(codArea1Field, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
        				.addComponent(telefonoField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
        				.addComponent(telefonoLabel)
        				.addComponent(celularLabel)
        				.addComponent(codArea2Field, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
        				.addComponent(celularField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
        			.addPreferredGap(ComponentPlacement.RELATED)
        			.addGroup(infoClientePanelLayout.createParallelGroup(Alignment.BASELINE)
        				.addComponent(emailLabel)
        				.addComponent(emailField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
        			.addPreferredGap(ComponentPlacement.RELATED)
        			.addGroup(infoClientePanelLayout.createParallelGroup(Alignment.TRAILING)
        				.addComponent(altaClienteLabel)
        				.addComponent(ultVisitaClienteDate, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
        				.addComponent(ultVisitaClienteLabel)
        				.addComponent(altaClienteDate, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
        			.addGap(43)
        			.addGroup(infoClientePanelLayout.createParallelGroup(Alignment.BASELINE)
        				.addComponent(guardarDatosClienteButton, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE)
        				.addComponent(btnEditar, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))
        			.addGap(20))
        );
        infoClientePanel.setLayout(infoClientePanelLayout);

        infoPacientePanel.setBorder(new TitledBorder(null, "Informaci\u00F3n de Paciente", TitledBorder.LEADING, TitledBorder.TOP, null, null)); // NOI18N
        infoPacientePanel.setName("infoPacientePanel"); // NOI18N

        idPacienteField.setEditable(false);
        idPacienteField.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        idPacienteField.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        idPacienteField.setName("idPacienteField"); // NOI18N
        idPacienteField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
            }
        });

        idPacienteLabel.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        idPacienteLabel.setText("ID:");
        idPacienteLabel.setName("idPacienteLabel"); // NOI18N

        nombrePacienteLabel.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        nombrePacienteLabel.setText("Nombre:");
        nombrePacienteLabel.setName("nombrePacienteLabel"); // NOI18N

        nombrePacienteField.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        nombrePacienteField.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        nombrePacienteField.setName("nombrePacienteField"); // NOI18N

        especieLabel.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        especieLabel.setText("Especie:");
        especieLabel.setName("especieLabel"); // NOI18N

        especieComboBox.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        especieComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Canino", "Felino\t", "Equino", " " }));
        especieComboBox.setName("especieComboBox"); // NOI18N

        razaLabel.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        razaLabel.setText("Raza:");
        razaLabel.setName("razaLabel"); // NOI18N

        razaComboBox.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        razaComboBox.setName("razaComboBox"); // NOI18N
        razaComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
              
            }
        });

        sexoLabel.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        sexoLabel.setText("Sexo:");
        sexoLabel.setName("sexoLabel"); // NOI18N

        sexoComboBox.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        sexoComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Macho", "Macho entero", "Macho castrado", "Hembra", "Hembra entera", "Hembra castrada" }));
        sexoComboBox.setName("sexoComboBox"); // NOI18N

        fNacLabel.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        fNacLabel.setText("Fecha de nacimiento:");
        fNacLabel.setName("fNacLabel"); // NOI18N

        fNacDate.setDateFormatString("d MMMMM yyyy"); // NOI18N
        fNacDate.setName("fNacDate"); // NOI18N

        edadLabel.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        edadLabel.setText("Edad:");
        edadLabel.setName("edadLabel"); // NOI18N

        pelajeLabel.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        pelajeLabel.setText("Pelaje:");
        pelajeLabel.setName("pelajeLabel"); // NOI18N

        pelajeField.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        pelajeField.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        pelajeField.setName("pelajeField"); // NOI18N

        edadField.setEditable(false);
        edadField.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        edadField.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        edadField.setName("edadField"); // NOI18N

        fAltaLabel.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        fAltaLabel.setText("Fecha de Alta:");
        fAltaLabel.setName("fAltaLabel"); // NOI18N

        fAltaDate.setMaxSelectableDate(new java.util.Date(253370779261000L));
        fAltaDate.setName("fAltaDate"); // NOI18N

        fUltVisitaLabel.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        fUltVisitaLabel.setText("Fecha de \u00FAltima visita:");
        fUltVisitaLabel.setName("fUltVisitaLabel"); // NOI18N

        fUltimaVisitaDate.setName("fUltimaVisitaDate"); // NOI18N
        fUltimaVisitaDate.setDate(new Date());

        microchipLabel.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        microchipLabel.setText("Microchip:");
        microchipLabel.setName("microchipLabel"); // NOI18N

        microchipField.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        microchipField.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        microchipField.setName("microchipField"); // NOI18N

        nuevoPacienteButton.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        nuevoPacienteButton.setText("Nuevo paciente");
        nuevoPacienteButton.setBorder(null);
        nuevoPacienteButton.setFocusable(false);
        nuevoPacienteButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        nuevoPacienteButton.setName("nuevoPacienteButton"); // NOI18N
        nuevoPacienteButton.setPreferredSize(new java.awt.Dimension(81, 19));
        nuevoPacienteButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        nuevoPacienteButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
         
            }
        });

        modificarPacienteButton.setText("Modificar");
        modificarPacienteButton.setName("modificarPacienteButton"); // NOI18N
        modificarPacienteButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
               
            }
        });

        guardarPacienteButton.setText("Guardar");
        guardarPacienteButton.setName("guardarPacienteButton"); // NOI18N
        guardarPacienteButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                
            }
        });
        abrirFichaButton = new javax.swing.JButton();
        
                abrirFichaButton.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
                abrirFichaButton.setText("Abrir ficha completa");
                abrirFichaButton.setBorder(null);
                abrirFichaButton.setFocusable(false);
                abrirFichaButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
                abrirFichaButton.setName("abrirFichaButton"); // NOI18N
                abrirFichaButton.setPreferredSize(new java.awt.Dimension(81, 19));
                abrirFichaButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
                abrirFichaButton.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                       
                    }
                });
      
        

        javax.swing.GroupLayout infoPacientePanelLayout = new javax.swing.GroupLayout(infoPacientePanel);
        infoPacientePanelLayout.setHorizontalGroup(
        	infoPacientePanelLayout.createParallelGroup(Alignment.LEADING)
        		.addGroup(infoPacientePanelLayout.createSequentialGroup()
        			.addContainerGap()
        			.addGroup(infoPacientePanelLayout.createParallelGroup(Alignment.LEADING)
        				.addGroup(infoPacientePanelLayout.createSequentialGroup()
        					.addGroup(infoPacientePanelLayout.createParallelGroup(Alignment.LEADING)
        						.addComponent(nombrePacienteLabel)
        						.addComponent(idPacienteLabel)
        						.addComponent(sexoLabel))
        					.addPreferredGap(ComponentPlacement.RELATED)
        					.addGroup(infoPacientePanelLayout.createParallelGroup(Alignment.LEADING)
        						.addGroup(infoPacientePanelLayout.createSequentialGroup()
        							.addComponent(idPacienteField, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
        							.addPreferredGap(ComponentPlacement.RELATED, 607, Short.MAX_VALUE)
        							.addComponent(modificarPacienteButton)
        							.addPreferredGap(ComponentPlacement.RELATED)
        							.addComponent(guardarPacienteButton))
        						.addGroup(infoPacientePanelLayout.createSequentialGroup()
        							.addGroup(infoPacientePanelLayout.createParallelGroup(Alignment.LEADING)
        								.addComponent(sexoComboBox, 0, 209, Short.MAX_VALUE)
        								.addComponent(nombrePacienteField, GroupLayout.DEFAULT_SIZE, 209, Short.MAX_VALUE)
        								.addComponent(fAltaDate, Alignment.TRAILING, GroupLayout.PREFERRED_SIZE, 162, GroupLayout.PREFERRED_SIZE))
        							.addGroup(infoPacientePanelLayout.createParallelGroup(Alignment.TRAILING)
        								.addComponent(fUltVisitaLabel)
        								.addGroup(infoPacientePanelLayout.createSequentialGroup()
        									.addGap(7)
        									.addComponent(especieLabel)
        									.addPreferredGap(ComponentPlacement.RELATED)
        									.addComponent(especieComboBox, 0, 90, Short.MAX_VALUE))
        								.addGroup(infoPacientePanelLayout.createSequentialGroup()
        									.addPreferredGap(ComponentPlacement.RELATED)
        									.addComponent(fNacLabel, GroupLayout.DEFAULT_SIZE, 157, Short.MAX_VALUE)))
        							.addPreferredGap(ComponentPlacement.RELATED)
        							.addGroup(infoPacientePanelLayout.createParallelGroup(Alignment.LEADING, false)
        								.addGroup(infoPacientePanelLayout.createSequentialGroup()
        									.addComponent(razaLabel)
        									.addPreferredGap(ComponentPlacement.RELATED)
        									.addComponent(razaComboBox, GroupLayout.PREFERRED_SIZE, 238, GroupLayout.PREFERRED_SIZE)
        									.addPreferredGap(ComponentPlacement.RELATED)
        									.addComponent(pelajeLabel)
        									.addPreferredGap(ComponentPlacement.RELATED)
        									.addComponent(pelajeField, GroupLayout.PREFERRED_SIZE, 119, GroupLayout.PREFERRED_SIZE))
        								.addGroup(infoPacientePanelLayout.createSequentialGroup()
        									.addComponent(fNacDate, GroupLayout.PREFERRED_SIZE, 153, GroupLayout.PREFERRED_SIZE)
        									.addPreferredGap(ComponentPlacement.RELATED)
        									.addComponent(edadLabel)
        									.addPreferredGap(ComponentPlacement.RELATED)
        									.addComponent(edadField))
        								.addGroup(infoPacientePanelLayout.createSequentialGroup()
        									.addComponent(fUltimaVisitaDate, GroupLayout.PREFERRED_SIZE, 151, GroupLayout.PREFERRED_SIZE)
        									.addPreferredGap(ComponentPlacement.RELATED)
        									.addComponent(microchipLabel)
        									.addPreferredGap(ComponentPlacement.RELATED)
        									.addComponent(microchipField))))))
        				.addComponent(fAltaLabel))
        			.addGap(20))
        		.addGroup(infoPacientePanelLayout.createSequentialGroup()
        			.addGap(229)
        			.addComponent(nuevoPacienteButton, GroupLayout.PREFERRED_SIZE, 195, GroupLayout.PREFERRED_SIZE)
        			.addGap(18)
        			.addComponent(abrirFichaButton, GroupLayout.PREFERRED_SIZE, 179, GroupLayout.PREFERRED_SIZE)
        			.addContainerGap(301, Short.MAX_VALUE))
        );
        infoPacientePanelLayout.setVerticalGroup(
        	infoPacientePanelLayout.createParallelGroup(Alignment.LEADING)
        		.addGroup(infoPacientePanelLayout.createSequentialGroup()
        			.addGroup(infoPacientePanelLayout.createParallelGroup(Alignment.LEADING)
        				.addGroup(infoPacientePanelLayout.createSequentialGroup()
        					.addContainerGap()
        					.addGroup(infoPacientePanelLayout.createParallelGroup(Alignment.BASELINE)
        						.addComponent(idPacienteLabel)
        						.addComponent(idPacienteField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
        				.addGroup(infoPacientePanelLayout.createParallelGroup(Alignment.BASELINE)
        					.addComponent(guardarPacienteButton)
        					.addComponent(modificarPacienteButton)))
        			.addPreferredGap(ComponentPlacement.RELATED)
        			.addGroup(infoPacientePanelLayout.createParallelGroup(Alignment.BASELINE)
        				.addComponent(nombrePacienteLabel)
        				.addComponent(nombrePacienteField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
        				.addComponent(especieLabel)
        				.addComponent(especieComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
        				.addComponent(razaLabel)
        				.addComponent(razaComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
        				.addComponent(pelajeLabel)
        				.addComponent(pelajeField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
        			.addPreferredGap(ComponentPlacement.RELATED)
        			.addGroup(infoPacientePanelLayout.createParallelGroup(Alignment.LEADING)
        				.addGroup(infoPacientePanelLayout.createParallelGroup(Alignment.BASELINE)
        					.addComponent(sexoLabel)
        					.addComponent(sexoComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
        					.addComponent(fNacLabel))
        				.addGroup(infoPacientePanelLayout.createParallelGroup(Alignment.BASELINE)
        					.addGroup(infoPacientePanelLayout.createSequentialGroup()
        						.addComponent(fNacDate, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
        						.addGap(3))
        					.addComponent(edadField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
        					.addComponent(edadLabel)))
        			.addPreferredGap(ComponentPlacement.RELATED)
        			.addGroup(infoPacientePanelLayout.createParallelGroup(Alignment.TRAILING)
        				.addGroup(infoPacientePanelLayout.createParallelGroup(Alignment.LEADING)
        					.addGroup(infoPacientePanelLayout.createSequentialGroup()
        						.addGap(3)
        						.addGroup(infoPacientePanelLayout.createParallelGroup(Alignment.TRAILING)
        							.addComponent(fAltaLabel)
        							.addGroup(infoPacientePanelLayout.createParallelGroup(Alignment.LEADING)
        								.addComponent(fUltVisitaLabel)
        								.addComponent(fUltimaVisitaDate, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
        					.addGroup(infoPacientePanelLayout.createParallelGroup(Alignment.BASELINE)
        						.addComponent(microchipLabel)
        						.addComponent(microchipField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
        				.addComponent(fAltaDate, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
        			.addGap(18)
        			.addGroup(infoPacientePanelLayout.createParallelGroup(Alignment.BASELINE)
        				.addComponent(nuevoPacienteButton, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE)
        				.addComponent(abrirFichaButton, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE))
        			.addContainerGap(47, Short.MAX_VALUE))
        );
        infoPacientePanel.setLayout(infoPacientePanelLayout);
       	
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        layout.setHorizontalGroup(
        	layout.createParallelGroup(Alignment.LEADING)
        		.addGroup(layout.createSequentialGroup()
        			.addContainerGap()
        			.addGroup(layout.createParallelGroup(Alignment.LEADING)
        				.addGroup(layout.createSequentialGroup()
        					.addComponent(nuevoClienteButton, GroupLayout.PREFERRED_SIZE, 192, GroupLayout.PREFERRED_SIZE)
        					.addContainerGap())
        				.addGroup(layout.createSequentialGroup()
        					.addGroup(layout.createParallelGroup(Alignment.TRAILING)
        						.addComponent(pacientesPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        						.addComponent(clientesPanel, GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE))
        					.addPreferredGap(ComponentPlacement.RELATED)
        					.addGroup(layout.createParallelGroup(Alignment.LEADING, false)
        						.addComponent(infoClientePanel, 0, 934, Short.MAX_VALUE)
        						.addComponent(infoPacientePanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        					.addContainerGap(46, Short.MAX_VALUE))))
        );
        layout.setVerticalGroup(
        	layout.createParallelGroup(Alignment.LEADING)
        		.addGroup(layout.createSequentialGroup()
        			.addContainerGap()
        			.addComponent(nuevoClienteButton, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE)
        			.addGap(58)
        			.addGroup(layout.createParallelGroup(Alignment.LEADING)
        				.addComponent(infoClientePanel, GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE)
        				.addComponent(clientesPanel, GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE))
        			.addPreferredGap(ComponentPlacement.RELATED)
        			.addGroup(layout.createParallelGroup(Alignment.LEADING)
        				.addGroup(layout.createSequentialGroup()
        					.addComponent(pacientesPanel, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
        					.addGap(43))
        				.addGroup(layout.createSequentialGroup()
        					.addComponent(infoPacientePanel, GroupLayout.DEFAULT_SIZE, 232, Short.MAX_VALUE)
        					.addContainerGap())))
        );
        
        JScrollPane scrollPane_1 = new JScrollPane();
        
        GroupLayout gl_pacientesPanel = new GroupLayout(pacientesPanel);
        gl_pacientesPanel.setHorizontalGroup(
        	gl_pacientesPanel.createParallelGroup(Alignment.TRAILING)
        		.addGroup(Alignment.LEADING, gl_pacientesPanel.createSequentialGroup()
        			.addContainerGap()
        			.addComponent(scrollPane_1, GroupLayout.DEFAULT_SIZE, 273, Short.MAX_VALUE)
        			.addContainerGap())
        );
        gl_pacientesPanel.setVerticalGroup(
        	gl_pacientesPanel.createParallelGroup(Alignment.LEADING)
        		.addGroup(gl_pacientesPanel.createSequentialGroup()
        			.addContainerGap()
        			.addComponent(scrollPane_1, GroupLayout.PREFERRED_SIZE, 136, GroupLayout.PREFERRED_SIZE)
        			.addContainerGap(27, Short.MAX_VALUE))
        );
        
       
        
        scrollPane_1.setColumnHeaderView(pacientesTable);
        
       getContentPane().setLayout(layout); 
       
       pacientesPanel.setLayout(gl_pacientesPanel);     
        
        JScrollPane scrollPane = new JScrollPane();
            
      
        
        GroupLayout gl_clientesPanel = new GroupLayout(clientesPanel);
        gl_clientesPanel.setHorizontalGroup(
        	gl_clientesPanel.createParallelGroup(Alignment.TRAILING)
        		.addGroup(gl_clientesPanel.createSequentialGroup()
        			.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        			.addGroup(gl_clientesPanel.createParallelGroup(Alignment.LEADING)
        				.addGroup(gl_clientesPanel.createSequentialGroup()
        					.addComponent(busquedaField, GroupLayout.PREFERRED_SIZE, 186, GroupLayout.PREFERRED_SIZE)
        					.addGap(12)
        					.addComponent(busquedaButton))
        				.addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 273, GroupLayout.PREFERRED_SIZE))
        			.addContainerGap())
        );
        gl_clientesPanel.setVerticalGroup(
        	gl_clientesPanel.createParallelGroup(Alignment.LEADING)
        		.addGroup(gl_clientesPanel.createSequentialGroup()
        			.addGap(5)
        			.addGroup(gl_clientesPanel.createParallelGroup(Alignment.BASELINE)
        				.addComponent(busquedaButton)
        				.addComponent(busquedaField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
        			.addGap(18)
        			.addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 236, Short.MAX_VALUE)
        			.addContainerGap())
        );
               	
     
        
        scrollPane.setColumnHeaderView(clientesTable);
        clientesPanel.setLayout(gl_clientesPanel);
        pack();        
        
        clientesTable.getTableHeader().setVisible(true);  // no funca!
        
        recuperarTablaClientes();
        
        setEstadoDeEdicionPaciente(false);

    } 	
     
   
        
    // </editor-fold>//GEN-END:initComponents  
    
    
 
    public void recuperarTablaClientes() {  	
    	
		
    	String[] elementos = new String[1];
    		
//    	ListIterator<Cliente> clientesIterator = clientes.listIterator();
/*
    	while (clientesIterator.hasNext()) {
    		
    		Cliente cliente = clientesIterator.next();		
    		elementos[0] = cliente.getNombre();
    		clientesTableModel.addRow(elementos);
    		
    	}*/
    }
 
       
    private Cliente clienteSeleccionado() {

    	Cliente cliente;
		
		int indice = clientesTable.getSelectedRow();
		
		cliente = null;//clientes.get(indice);
		
		return cliente;
    	
    }
    
    
    private ArrayList<Paciente> pacientesParaClienteSeleccionado () {

    	Cliente cliente = clienteSeleccionado();		
		
		ArrayList<Paciente> pacientes = null;//dao.getPacientes(cliente.getId());
		
		return pacientes;
    }
    
  	
	private void MostrarDatosDeTablaClientes () {      // muestra los datos del cliente seleccionado en los campos y los pacientes correspondientes
/*
		Cliente cliente = clienteSeleccionado();
		
		ArrayList<Paciente> pacientes = pacientesParaClienteSeleccionado();		
				
		idField.setText(Integer.toString(cliente.getCodigo()));
		nombreApellidoField.setText(cliente.getNombre());
		direccionField.setText(cliente.getDireccion());	
		cpComboBox.setSelectedItem(cliente.getCp());
		localidadComboBox.setSelectedItem(cliente.getLocalidad());
		provinciaComboBox.setSelectedItem(cliente.getProvincia());
		codArea1Field.setText(cliente.getCodArea1());
		telefonoField.setText(cliente.getTelefono());
		codArea2Field.setText(cliente.getCodArea2());
		celularField.setText(cliente.getCelular());
		emailField.setText(cliente.getEmail());
				
		mostrarPacientesParaClienteSeleccionado(pacientes);
		
*/
	}
	
	
	public void mostrarPacientesParaClienteSeleccionado(ArrayList<Paciente> pacientes) {
		
		String[] elementos = new String[1];		
		
    	ListIterator<Paciente> pacientesIterator = pacientes.listIterator();
    	
    	
    	while (pacientesIterator.hasNext()) {
    		
    		Paciente paciente = pacientesIterator.next();
    		elementos[0] = paciente.getNombre();
    		pacientesTableModel.addRow(elementos); 
    		
    
    	}
	}
		
    
    public void mostrarDatosDeTablaPacientes() {
    
    	ArrayList<Paciente> pacientes;
    	int indice;
    	Paciente paciente;
        	
    	pacientes = pacientesParaClienteSeleccionado();
    	indice = pacientesTable.getSelectedRow();
    	paciente = pacientes.get(indice);    	
   
    	idPacienteField.setText(Integer.toString(paciente.getId()));
    	nombrePacienteField.setText(paciente.getNombre());
    	especieComboBox.setSelectedItem(paciente.getEspecie());
    	razaComboBox.setSelectedItem(paciente.getRaza());
    	pelajeField.setText(paciente.getPelaje());
    	sexoComboBox.setSelectedItem(paciente.getSexo());
//    	fNacDate.setDate(paciente.getFechaNacimiento());
//    	fUltimaVisitaDate.setDate(paciente.getFechaUltimaVisita());
    	microchipField.setText(paciente.getMicrochip());   	
    	
    }
    	
    private void borrarDatosPacienteEnCampos() {
    	
    	idPacienteField.setText("");
    	nombrePacienteField.setText("");
    	especieComboBox.setSelectedItem("");
    	razaComboBox.setSelectedItem("");
    	pelajeField.setText("");
    	sexoComboBox.setSelectedItem("");
    	fNacDate.setDate(null);
    	fUltimaVisitaDate.setDate(null);
    	microchipField.setText("");
    	
    }	
		

	private void setEstadoDeEdicionPaciente(boolean isEdicion) {
		
		idPacienteField.setEnabled(isEdicion);
		idPacienteField.setDisabledTextColor(getForeground());
    	nombrePacienteField.setEnabled(isEdicion);
    	nombrePacienteField.setDisabledTextColor(getForeground());
    	especieComboBox.setEnabled(isEdicion);
    	
    	razaComboBox.setEnabled(isEdicion);
    	
    	pelajeField.setEnabled(isEdicion);
    	pelajeField.setDisabledTextColor(getForeground());
    	sexoComboBox.setEnabled(isEdicion);
    	
    	fNacDate.setEnabled(isEdicion);
    	
    	fUltimaVisitaDate.setEnabled(isEdicion);
    	
    	microchipField.setEnabled(isEdicion);
    	microchipField.setDisabledTextColor(getForeground());
		
		
	}

	private void setEstadoDeEdicionCliente(boolean isEdicion) {     // activa o desactiva elementos 
		
		idField.setEnabled(!isEdicion);
		idField.setDisabledTextColor(getForeground());
		nombreApellidoField.setEnabled(isEdicion);
		nombreApellidoField.setDisabledTextColor(getForeground());
		direccionField.setEnabled(isEdicion);
		direccionField.setDisabledTextColor(getForeground());
		cpComboBox.setEnabled(isEdicion);		
		localidadComboBox.setEnabled(isEdicion);
		provinciaComboBox.setEnabled(isEdicion);
		codArea1Field.setEnabled(isEdicion);
		codArea1Field.setDisabledTextColor(getForeground());
		codArea2Field.setEnabled(isEdicion);
		codArea2Field.setDisabledTextColor(getForeground());
		telefonoField.setEnabled(isEdicion);		
		telefonoField.setDisabledTextColor(getForeground());
		celularField.setEnabled(isEdicion);
		celularField.setDisabledTextColor(getForeground());
		emailField.setEnabled(isEdicion);
		emailField.setDisabledTextColor(getForeground());
		altaClienteDate.setEnabled(isEdicion);		
		ultVisitaClienteDate.setEnabled(isEdicion);
		nuevoClienteButton.setEnabled(!isEdicion);
		eliminarClienteButton.setEnabled(!isEdicion);
		btnEditar.setEnabled(!isEdicion);
		altaClienteDate.setEnabled(isEdicion);
		ultVisitaClienteDate.setEnabled(isEdicion);
		
	}



    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) throws Exception {
    	
    	
    	java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
            	try {
            		ClienteFrame clientesFrame = new ClienteFrame();
            		JDesktopPane jDesktop = new JDesktopPane();
                	jDesktop.add(clientesFrame);
                	clientesFrame.setVisible(true);	                	    	
                
            	}
            	catch(Exception e) {
            		
            		
            	}

            }
        });
    }
}

   